﻿Imports System.Data.OleDb
Public Class Resgister
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        Dim objBl = New BL()
        ''Dim objDal = New DL()

        Dim dbconn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("/App_Data/KitchenCompition.mdb"))

        Dim strSelect As String = "select * from Register where EmailAdd='" & txtEmail.Text & "'"
        Dim dt As DataTable = objBl.GetDataAccess(strSelect, dbconn)

        If dt.Rows.Count > 0 Then
            lbError.Text = "The Email address already exists. Please try another"
        Else
            Dim strInsert As String = "insert into Register(FullName,EmailAdd,UserPassword,Pic) Values("
            strInsert += "'" & txtName.Text & "',"
            strInsert += "'" & txtEmail.Text & "',"
            strInsert += "'" & txtPassword.Text & "',"
            strInsert += "'abcd')"

            objBl.GetInsertUpdate(strInsert, dbconn)
            Dim strSelectOrder As String = "select top 1 * from Register order by userid desc"
            Dim dtSession As DataTable = objBl.GetDataAccess(strSelectOrder, dbconn)
            Session("UserId") = dtSession.Rows(0)("UserId").ToString
            Session("EmailId") = txtEmail.Text
            Response.Redirect("myRecipe.aspx")
        End If


       




    End Sub
End Class